package mpYoga

import (
	"duoke/model/yogaModel"
	yogaService "duoke/service/yoga"
	"duoke/utils/gconv"
	"duoke/utils/request"
	"duoke/utils/response"
	"github.com/gin-gonic/gin"
)

var SchoolTimetable = new(schoolTimetableCtl)

type schoolTimetableCtl struct{}

func (ctl *schoolTimetableCtl) List(c *gin.Context) {
	req := request.JsonMap(c)
	id := gconv.Int(req["id"])
	if id == 0 {
		response.Error(c, "参数缺失【id】", nil)
		return
	}
	classType := gconv.Int(req["type"])
	if classType == 0 {
		response.Error(c, "参数缺失【type】", nil)
		return
	}
	list, err := yogaService.SchoolTimetable.List(&yogaModel.ReqSchoolTimetable{
		ClassId:   id,
		ClassType: classType,
	})
	if err != nil {
		response.Error(c, err.Error(), nil)
		return
	}
	response.Success(c, "success", list)
}
func (ctl *schoolTimetableCtl) GroupClass(c *gin.Context) {
	var req yogaModel.SearchSchoolTimetable
	if err := c.ShouldBind(&req); err != nil {
		response.Error(c, err.Error(), nil)
		return
	}
	class, err := yogaService.SchoolTimetable.GroupClass(&req)
	if err != nil {
		response.Error(c, err.Error(), nil)
		return
	}
	response.Success(c, "success", class)
}
func (ctl *schoolTimetableCtl) Teacher(c *gin.Context) {
	var req yogaModel.SearchSchoolTimetable
	if err := c.ShouldBind(&req); err != nil {
		response.Error(c, err.Error(), nil)
		return
	}
	class, err := yogaService.SchoolTimetable.Teacher(&req)
	if err != nil {
		response.Error(c, err.Error(), nil)
		return
	}
	response.Success(c, "success", class)
}
